package business {

    import com.adobe.cairngorm.business.ServiceLocator;
    
    import mx.collections.*;
    import mx.rpc.*;
    import mx.rpc.remoting.*;
	
    public class UserDelegate
    {
		private var responder:Object;
        private var service:RemoteObject;

        public function UserDelegate(re:Object)
        {
	        this.service = ServiceLocator.getInstance().getRemoteObject("userService");
            this.responder = re;
        }
        
        public function getUsers(page:int):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getUsers(page);
            itemResponder = new ItemResponder(responder["getUsersResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function getUsersByAudit(page:int=0,range:String="all"):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getUsersByAudit(page,range);
            itemResponder = new ItemResponder(responder["getUsersByAuditResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function getUsersBySearch(pattern:String, type:String, page:int=0):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getUsersBySearch(pattern,type,page);
            itemResponder = new ItemResponder(responder["getUsersBySearchResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
		
		public function getUsersById(id:int):void
		{
			var token:AsyncToken;
			var itemResponder:ItemResponder;
			token = service.getUsersById(id);
			itemResponder = new ItemResponder(responder["getUsersByIdResult"],responder["fault"] );
			token.addResponder(itemResponder);
		}
		
		public function getUsersByIds(id:*):void
		{
			var token:AsyncToken;
			var itemResponder:ItemResponder;
			token = service.getUsersById(id);
			itemResponder = new ItemResponder(responder["getUsersByIdsResult"],responder["fault"] );
			token.addResponder(itemResponder);
		}
        
        public function updateUsers(ids:Array,update:Object):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.updateUsers(ids,update);
            itemResponder = new ItemResponder(responder["updateUsersResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function clearPic(id:int):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.clearPic(id);
            itemResponder = new ItemResponder(responder["clearPicUserResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function registerUserSys(bid:String,password:String,email:String):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.registerUserSys(bid,password,email);
            itemResponder = new ItemResponder(responder["registerUserSysResult"],responder["fault"] );
            token.addResponder(itemResponder);
        }
        
        public function sendMsgRecom(bid:String):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.sendMsgRecom(bid);
            itemResponder = new ItemResponder(responder["sendMsgRecomResult"],responder["fault"] );
            token.addResponder(itemResponder);        	
        } 

		/**
		 * isCount = 是否统计
		 * status = 0 等待审核
		 * status = 1 审核通过
		 * status = 2 审核拒绝
		 */        
        public function getApplySuperList(page:int=1, status:String='0', pageSize:int=20, order:String='', isCount:Boolean=true ):void   
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getApplySuperList(page, pageSize, order, isCount, status);
            itemResponder = new ItemResponder(responder["getApplySuperListResult"],responder["fault"] );
            token.addResponder(itemResponder);           	
        }
        
        public function pastApply( bid:String, action:String='1', msg:String="" ):void
        {
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.pastApply(bid, action, msg );
            itemResponder = new ItemResponder(responder["pastApplyResult"],responder["fault"] );
            token.addResponder(itemResponder);           	
        }
        
        /**
         * 查看用户爱拍币
         * @param bid 用户ID
         * @return void
         */
        public function getMoney(bid:String):void
        {
        	var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.getMoney(bid);
            itemResponder = new ItemResponder(responder["getMoneyResult"],responder["getMoneyFault"] );
            token.addResponder(itemResponder);
        }

		/**
		 * 奖罚用户爱拍币
		 * @param bin 用户ID
		 * @param num 爱拍币，正数表示奖赏，负数表示扣除
		 * @param payType 操作类型，101代表'系统操作'
		 * @param info 操作信息（赠送、惩罚理由）
		 */
		public function addMoney(bid:String, num:String, payType:int=101, info:String="系统赠送"):void
		{
            var token:AsyncToken;
            var itemResponder:ItemResponder;
            token = service.addMoney(bid, num, payType, info);
            itemResponder = new ItemResponder(responder["addMoneyResult"],responder["addMoneyFault"] );
            token.addResponder(itemResponder);
		}
		
		public function addMoneys(arr:Array):void
		{
			var token:AsyncToken;
			var itemResponder:ItemResponder;
			token = service.addMoneys(arr);
			itemResponder = new ItemResponder(responder["addMoneysResult"],responder["fault"] );
			token.addResponder(itemResponder);
		}
		
		public function getOrderHistory(startTime:*, endTime:*, bid:*, index:*=1,limit:int=20):void
		{
			var token:AsyncToken;
			var itemResponder:ItemResponder;
			token = service.getOrderHistory(startTime, endTime, bid, index, limit);
			itemResponder = new ItemResponder(responder["getOrderHistoryResult"],responder["fault"] );
			token.addResponder(itemResponder);
		}
		
		
    }
}

